package study.async.springboot.support.async;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import study.job.spring.support.executor.NamedThreadFactory;

import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * （1）使用 jdk 提供的执行器 ScheduledThreadPoolExecutor
 */
@Slf4j
@Configuration
public class _2_AsyncConfig {

    @Bean("executor_2")
    public Executor executor02() {
        //jdk 提供执行器
        ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(5);
        //
        executor.setMaximumPoolSize(5);
        executor.setThreadFactory(new NamedThreadFactory("jdk"));
        return executor;
    }
}
